package cn.school.web;

import cn.school.entity.Student;
import cn.school.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "ShowStudentServlet",value = "/showStudentServlet")
public class ShowStudentServlet extends HttpServlet {
    StudentService studentService=new StudentService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        long stuno=Long.parseLong(request.getParameter("stuno"));
        Student s=studentService.get(stuno);
        request.setAttribute("stu",s);
        request.getRequestDispatcher("studentshow.jsp").forward(request,response);
    }
}
